"""多对多added

Revision ID: fb357b235baa
Revises: 37631621638b
Create Date: 2025-10-29 12:02:55.091196

"""
from typing import Sequence, Union

from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision: str = 'fb357b235baa'
down_revision: Union[str, Sequence[str], None] = '37631621638b'
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None


def upgrade() -> None:
    """Upgrade schema."""
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('tb_role_players',
    sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
    sa.Column('role_name', sa.String(length=50), nullable=False),
    sa.Column('create_time', sa.DateTime(), nullable=False, comment='记录的创建时间'),
    sa.Column('update_time', sa.DateTime(), nullable=False, comment='记录最后一次修改的时间'),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('tb_users',
    sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
    sa.Column('username', sa.String(length=50), nullable=False, comment='用户名'),
    sa.Column('password', sa.String(length=20), nullable=False),
    sa.Column('create_time', sa.DateTime(), nullable=False, comment='记录的创建时间'),
    sa.Column('update_time', sa.DateTime(), nullable=False, comment='记录最后一次修改的时间'),
    sa.PrimaryKeyConstraint('id'),
    sa.UniqueConstraint('username')
    )
    op.create_table('t_user_roles',
    sa.Column('user_id', sa.Integer(), nullable=False),
    sa.Column('roler_id', sa.Integer(), nullable=False),
    sa.ForeignKeyConstraint(['roler_id'], ['tb_role_players.id'], ),
    sa.ForeignKeyConstraint(['user_id'], ['tb_users.id'], ),
    sa.PrimaryKeyConstraint('user_id', 'roler_id')
    )
    # ### end Alembic commands ###


def downgrade() -> None:
    """Downgrade schema."""
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_table('t_user_roles')
    op.drop_table('tb_users')
    op.drop_table('tb_role_players')
    # ### end Alembic commands ###
